package com.tmt.im.manager.controller.api;

import com.tmt.im.common.enums.IMRoleEnum;
import com.tmt.im.manager.controller.vo.CustomerInfoVo;
import com.tmt.im.manager.controller.vo.VersionInfoVo;
import com.tmt.im.manager.service.IMUserService;
import com.tmt.im.manager.service.SystemParamService;
import com.tmt.springboot.common.restful.IExecuteResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.concurrent.CompletableFuture;

/**
 * @Description TODO
 * @Author wuyi
 * @Date 2024/9/20 16:06
 * @Version 1.0
 **/
@Async("asyncTaskExecutor")
@Tag(name = "系统相关参数接口", description = "系统相关参数接口")
@RestController
@RequestMapping("${api-url-prefix}/param")
public class SystemParamController {

    private final SystemParamService systemParamService;

    public SystemParamController(SystemParamService systemParamService){
        this.systemParamService = systemParamService;
    }

    @Operation(summary = "检查最新版本信息",
            description = "检查最新版本信息",
            operationId = "versionCheck",
            parameters = {
                    @Parameter(name = "appType", description = "App端类型(同设备类型)：ANDROID或IOS", required = true)
            })
    @GetMapping("/version/{appType}")
    public CompletableFuture<IExecuteResult<VersionInfoVo>> versionCheck(@PathVariable("appType") String appType,  Principal principal) {
        IExecuteResult<VersionInfoVo> result = systemParamService.getVersionInfo(appType);
        return CompletableFuture.completedFuture(result);
    }

}
